﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Caching;
using System.Web.Services;
using System.Web.Script.Services;
using Box.BL;

using Box.Entities;
using Microsoft.Practices.Unity;
using Microsoft.Practices.Unity.Configuration;
using Newtonsoft.Json;
//using Formatting = System.Xml.Formatting;

namespace Box.Cliente
{
    /// <summary>
    /// Descripción breve de servicioVentas
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // Para permitir que se llame a este servicio web desde un script, usando ASP.NET AJAX, quite la marca de comentario de la línea siguiente. 
    // [System.Web.Script.Services.ScriptService]

    [ScriptService]
    public class servicioVentas : System.Web.Services.WebService
    {
        
        [Dependency]
        public IProductoBL _productoBl { get; set; }
        public servicioVentas()
        {
            using (var container = new UnityContainer())
            {
                container.LoadConfiguration();
                container.BuildUp(this.GetType(), this);
            }
        }

        [WebMethod]
        public string StockBajoProductos()
        {
            var query = _productoBl.ExisteProductoStockBajo();
            Dictionary<string, string> response = new Dictionary<string, string>();
            response.Add("Response", query.ToString());
            return JsonConvert.SerializeObject(response, Formatting.Indented);

        }


        [WebMethod]
        public string HelloWorld()
        {
            return "Hola a todos";
        }
    }
}
